package com.info33.platform.system.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.info33.platform.business.app.dto.AppUpdateDTO;
import com.info33.platform.common.mvc.entity.BaseEntity;
import com.info33.platform.system.dto.SysUserDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Null;

/**
 * 系统 - 用户 - 登录信息
 *
 * @author admin
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SysUser extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @NotEmpty(groups = {SysUserDTO.PasswordLogin.class,
            SysUserDTO.SaveUser.class,
            SysUserDTO.UpdateUser.class,
            SysUserDTO.AppPassWordLogin.class,
            SysUserDTO.AppCheckLoginName.class}, message = "登录名不能为空")
    @ApiModelProperty(value = "登录名")
    private String loginName;

    @NotEmpty(groups = {SysUserDTO.SaveUser.class})
    @ApiModelProperty(value = "真实姓名")
    @TableField(exist = false)
    private String trueName;

    @ApiModelProperty(value = "昵称")
    @TableField(exist = false)
    private String nickName;

    @ApiModelProperty(value = "头像 url")
    @TableField(exist = false)
    private String headImg;

    @Null(groups = {SysUserDTO.AppChange.class}, message = "手机号不可修改")
    @NotEmpty(groups = {SysUserDTO.MessagePush.class,
            SysUserDTO.MessageLogin.class,
            SysUserDTO.SaveUser.class,
            SysUserDTO.UpdateUser.class,
            SysUserDTO.ForgetPassword.class}, message = "手机号不能为空")
    @ApiModelProperty(value = "手机号")
    private String mobile;

    @Null(groups = {SysUserDTO.AppChange.class,
            AppUpdateDTO.AppUpdate.class}, message = "密码必须为空")
    @NotBlank(groups = {SysUserDTO.PasswordLogin.class,
            SysUserDTO.ChangePassword.class,
            SysUserDTO.AppPassWordLogin.class,
            SysUserDTO.ChangePasswordByCode.class,
            SysUserDTO.ForgetPassword.class}, message = "密码不能为空")
    @ApiModelProperty(value = "密码")
    private String password;

    @Null(groups = {SysUserDTO.AppChange.class,
            AppUpdateDTO.AppUpdate.class}, message = "盐值不可修改")
    @ApiModelProperty(value = "盐值")
    private String salt;

}